package bch.maven.plugin.guava;

import com.google.common.collect.LinkedHashMultiset;
import com.google.common.collect.Multiset;

public class LinkedHashMultisetExample {
    public static void main(String[] args) {
        Multiset<String> multiset = LinkedHashMultiset.create();

        multiset.add("apple");
        multiset.add("banana");
        multiset.add("apple");
        multiset.add("orange");
        multiset.add("banana");
        multiset.add("apple");

        System.out.println("完整 multiset：" + multiset);
        System.out.println("apple 出现次数：" + multiset.count("apple"));
        System.out.println("唯一元素列表：" + multiset.elementSet());
        System.out.println("按插入顺序遍历：");
        multiset.forEach(System.out::println);
    }
}
